{% extends('layout.html') %}
{% block body %}
<!-- Tabs for statistics -->
<section id="dropdown" class="section">
    <div class="container">
        <div class="col s12 m12">
            <div class="card-panel">
                <h4 class="red-text">System Logs</h4>
                <div class="row">
                    <form action="system/logs" method="POST">
                        <div class="input-field col s10 m6">
                            <select name="table" onchange="this.form.submit()">
                                {% for selection in
                                    ['combined', 'system', 'update', 'logins', 'dns_proxy', 'ip_proxy', 'ips', 'dhcp_server', 'syslog'] %}
                                <option value="{{selection}}" {% if menu==loop.index|string %} selected {% endif %}
                                    >{{selection.upper()|replace('_', ' ')}} LOG</option>
                                {% endfor %}
                            </select>
                            <label for="table">Log Files</label>
                        </div>
                        <noscript>
                            <div class="input-field col s3 m3">
                                <button class="btn waves-effect waves-light col s4">
                                    <i class="material-icons">cached</i>
                                </button>
                            </div>
                        </noscript>
                    </form>
                </div>
                <div class="row">
                    <table class="striped">
                        <thead>
                            <tr>
                                <th>Date/Time</th>
                                <th>Service</th>
                                <th>Level</th>
                                <th>Log Entry</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% if table_data %}
                            {% for date_time, service, log_level, log_entry in table_data %}
                            <tr>
                                <td>{{date_time}}</td>
                                <td>{{service}}</td>
                                <td>{{log_level}}</td>
                                <td>{{log_entry}}</td>
                            </tr>
                            {% endfor %}
                            {% else %}
                            <tr>
                                <td>No Logs</td>
                                <td></td>
                            </tr>
                        </tbody>
                        {% endif %}
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
{% endblock %}